/**
 * 
 */
package name.shamansir.tadah.data;

import java.util.ArrayList;
import java.util.List;

/**
 * <dl>
 * <dt>Project:</dt> <dd>ta-dah</dd>
 * <dt>Package:</dt> <dd>name.shamansir.tadah.data</dd>
 * </dl>
 *
 * <code>Tag</code>
 *
 * <p>Description</p>
 *
 * @author Ulric Wilfred <shaman.sir@gmail.com>
 * @date Feb 21, 2011 9:22:18 PM 
 *
 */
public class Tag {
    
    public static enum Type { NORMAL, PROJECT, LOCATION }
    
    private final Type type;
    private final String name;
    
    private final List<String> mistypes = new ArrayList<String>();

    public Tag(String name) {
        this(null, name);
    }
    
    public Tag(Type type, String name) {
        this.type = (type != null) ? type : Type.NORMAL;
        this.name = name;
    }
    
    public String getName() { return this.name; }
    
    public Type getType() { return this.type; }
    
    public void addMistype(String mistype) {
        this.mistypes.add(mistype);
    }
    
    public boolean matchesMistype(String mistype) {
        // FIXME: implement
        return false;
    }
    
    @Override
    public int hashCode() {
        return (type.hashCode() << 7) & name.hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof Tag))
            return false;
        Tag t = (Tag)o;
        return type.equals(t.type) && name.equals(t.name);        
    }

}
